# Copyright: (C) 2010 RobotCub Consortium
# Authors: Lorenzo Natale
# CopyPolicy: Released under the terms of the GNU GPL v2.0.

yarp_prepare_plugin(ecan
    CATEGORY device
    TYPE yarp::dev::EsdCan
    INCLUDE EsdCan.h )

IF (NOT SKIP_ecan)
  FIND_PACKAGE(ESDCANAPI)
  
  IF(NOT ESDCANAPI_FOUND)
    MESSAGE(SEND_ERROR "ecan: cannot find esdcan api, turn off device")
  ELSE(NOT ESDCANAPI_FOUND)
    # Print out library location
    MESSAGE(STATUS " ++++ ESD CAN library found at: ${ESDCANAPI_LIB}")
    MESSAGE(STATUS " ++++ ESD CAN include files found at: ${ESDCANAPI_INC_DIRS}")
    
    INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${ESDCANAPI_INC_DIRS})
    yarp_add_plugin(esdCan EsdCan.cpp EsdCan.h)
    
    TARGET_LINK_LIBRARIES(esdCan ${ESDCANAPI_LIB} ${YARP_LIBRARIES})
    
    icub_export_plugin(esdCan)

  yarp_install(TARGETS esdCan
               COMPONENT Runtime
               LIBRARY DESTINATION ${ICUB_DYNAMIC_PLUGINS_INSTALL_DIR}
               ARCHIVE DESTINATION ${ICUB_STATIC_PLUGINS_INSTALL_DIR}
               YARP_INI DESTINATION ${ICUB_PLUGIN_MANIFESTS_INSTALL_DIR})

  ENDIF(NOT ESDCANAPI_FOUND)

ENDIF (NOT SKIP_ecan)
